<?php
/**
 * Created by PhpStorm.
 * User: mojie126
 * Date: 2017/7/5 0005
 * Time: 上午 11:17
 */

namespace app\index\controller;


class DeleteController extends Base
{
	public function index($id, $type)
	{
		$this->checkAccess();
		$db = getTorrentDB($type);
		$where = [
			"id" => ["=", $id],
			"display" => ["=", "0"],
			"status" => ["=", "0"]
		];

		$res = db($db)->where($where)->field(["id", "torrentpath"])->find();
		if ($res) {
			$row = db($db)->where("id", $res['id'])->delete();
			if ($row) {
				@unlink(ROOT_PATH . "public" . DS . "torrents" . DS . $res['torrentpath']);
				$this->success("删除成功", "/index/$db");
			} else {
				$this->error("没找到相关信息啊！（｡◕ˇ＿ˇ◕｡）");
			}
		} else {
			$this->error("没找到相关信息啊！（｡◕ˇ＿ˇ◕｡）");
		}
	}
}